<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('市级未签收M')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNo"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                            <a class="btn btn-info btn-rounded btn-sm" onclick="sameSearch()"><i
                                    class="fa fa-send"></i>&nbsp;同源派单</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success single disabled" onclick="$.operate.handleTab()">
                <i class="fa fa-plus"></i> 处理
            </a>
            <a class="btn btn-success multiple disabled" onclick="printX()">
                <i class="fa fa-print"></i> 转办单
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/mMailWF";
    var cmnTab = ctx + "system/cmnTab";

    function printX() {
        var url = prefix+"/forShow/printSends";
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length < 2) {
            url += "?ids="+row[0].myPkVal;
        }else {
            var ids = '';
            for (let i = 0; i < row.length; i++) {
                ids += row[i].myPkVal;
                if ((i+1) != row.length) {
                    ids += ","
                }
            }
            url += "?ids="+ids;
        }
        window.open(url,"printX",'left=100,top=20,height=700,width=720,toolbar=yes,menubar=yes,scrollbars=auto');

    }

    $(function () {
        var options = {
            url: prefix + "/cmnFile/signNotListJson",
            sortName: "myPkVal",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            updateUrl: cmnTab+"/mwfCSignS/{id}",
            // removeUrl: "/system/sendBack/remove",
            modalName: "市级未签收M",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            rowStyle: rowStyle,
            columns: [{
                checkbox: true
            },
                {field:'myPkVal',title:'pkid',visible:false},
                {field:'WfId',title:'WfId',visible:false},
                {field:'myMwfNO',title:'工单编号',align:'center',halign:'center'},
                {field:'SpareString',title:'信件来源',align:'center',halign:'center',sortable:true, formatter:function(value,row,index) {
                        return value == '互联网+督查' ? '<span style="color:red;">'+value+'</span>' : value;
                    }},
                {field:'myMwfTopic',title:'工单主题',align:'center',halign:'center',
                    formatter:function (value, row, index,field) {
                        var obj = rowStyle(row)
                        if(obj == '')
                            return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                        if(obj.css.color == 'blue')
                            return "<span style='cursor: pointer;color: blue;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                        else if(obj.css.color == 'red')
                            return "<span style='cursor: pointer;color: red;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field: 'FmContent', title: '工单内容', align: 'center',formatter:function (value, row, index,field) {
                        var obj = rowStyle(row)
                        if(obj == '')
                            return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                        if(obj.css.color == 'blue')
                            return "<span style='cursor: pointer;color: blue;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                        else if(obj.css.color == 'red')
                            return "<span style='cursor: pointer;color: red;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis},
                {field:'SeqName',title:'交办次序',align:'center',sortable:true},
                {field:'SortName',title:'性质',align:'center',sortable:true},
                {field:'DealName',title:'办理方式',align:'center',sortable:true},
                {field:'bkLimit',title:'办理期限',align:'center'},
                {field:'SDeptName',title:'派发单位',align:'center',halign:'center',sortable:true},
                {field:'sdDate',title:'派发日期',align:'center'},
                {field:'SendRemark',title:'备注',align:'center',halign:'center',
                    formatter:function (value, row, index,field) {
                        var obj = rowStyle(row)
                        if(obj == '')
                            return "<span style='cursor: pointer;' title='"+value+"'>"+value+"</span>"
                        if(obj.css.color == 'blue')
                            return "<span style='cursor: pointer;color: blue;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                        else if(obj.css.color == 'red')
                            return "<span style='cursor: pointer;color: red;font-weight: bold;' title='"+value+"'>"+value+"</span>"
                    },
                    cellStyle: cellEllipsis
                },
                {field:'FlagString',title:'转办情况',align:'center',halign:'center',sortable:true},
                {
                    title: '操作',
                    align: 'center',
                    events: "operateEvents",
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.handleTab(\'' + row.myPkVal + '\',\'信件工单签收处理\')"><i class="fa fa-edit"></i>处理</a> ');
                        actions.push('<a id="id_row_tosend" class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>转派</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    window.operateEvents = {
        "click #id_row_tosend": function (e, value, row, index) {
            // var wfId = row.wfId;
            var sbId = row.myPkVal;
            // transferSendToSon(wfId,sbId);
            dlSendToSon(sbId);
        }
    }

    //转派
    function transferSendToSon(wfId,sbId) {
        var url = ctx + "system/mTelWF/cmnFile/transferSendToSon/"+wfId+"?sbId="+sbId;
        var width = '85%';
        var height = '95%';
        var config = {
            id: 'dlSendToSon',
            title: '拟办部门',
            width: width,
            height: height,
            url: url,
            callBack: function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            }
        };
        $.modal.openOptions(config);
    }

    function dlSendToSon(sbId) {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        if(!(sbId)){
            sbId = row[0].myPkVal;
        }
        var url = cmnTab + "/mwfCSendWait/"+sbId;
        var width = '85%';
        var height = '95%';
        var config = {
            id: 'dlSendToSon',
            title: '拟派下级部门',
            width: width,
            height: height,
            url: url,
            yes: function (index, layero) {
                var iframeWin = layero.find('iframe')[0];
                var diagId = 2;
                iframeWin.contentWindow.document.getElementById('navFrame').contentWindow.submitHandler(index, diagId, 2);
            }
        };
        $.modal.openOptions(config);
    }

    function sameSearch(){
        var btn = ['<i class="fa fa-check"></i> 同源派单', '<i class="fa fa-close"></i> 取消派单'];
        var options = {
            width: '75%',
            height: '90%',
            title: '同源派单',
            url: prefix + "/cmnFile/searchForm",
            btn: btn,
            callBack: function (index, layero){
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            }
        };
        $.modal.openOptions(options);
    }
</script>
</body>
</html>